package com.ebupt.migu.music.commons.selfdom.demo.impl;

import com.ebupt.migu.globalpopup.entity.ConditionRelation;
import com.ebupt.migu.globalpopup.enums.ConditionEnum;
import com.ebupt.migu.music.commons.selfdom.demo.Member;
import com.ebupt.migu.music.commons.selfdom.demo.impl.identifier.AbstractIdentifierEnImpl;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 会员子条件实现类
 *
 * @author wangzhu
 * @since 2021-12-31
 */
public class MemberImpl extends AbstractIdentifierEnImpl implements Member {
    /**
     * 非会员
     */
    private boolean noVIP(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 特级会员
     */
    private boolean superVIP(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 白金+特级会员
     */
    private boolean psVIP (String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     *白金会员
     */
    private boolean platinaVIP(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 大站包
     */
    private boolean bigStation(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 联合会员V
     */
    private boolean uniteVIP(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 白金会员体验版
     */
    private boolean explatinaVIP (String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 小时包
     */
    private boolean hour (String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 5G畅玩包
     */
    private boolean fiveG(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 音乐包（客户端730去掉）
     */
    private boolean music (String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * 非音乐包（客户端730去掉）
     */
    private boolean noMusic (String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * ikun会员
     */
    private boolean ikunVIP(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }

    /**
     *白金会员尝鲜版
     */
    private boolean cxplatinaVIP(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }

    /**
     *  白金会员畅听版（20210610新增）
     */
    private boolean  ctplatinaVIP(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }

    /**
     * 日享包（20210610新增）
     */
    private boolean dayAt(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }

    /**
     * M_ZONE(20210817新增)
     */
    private boolean M_ZONE(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }

    /**
     * 自定义ID（直接以业务ID进行区分；精准配置，避免新增或减少某个业务ID）
     */
    private boolean custom (String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }
    /**
     * M_ZONE 尝鲜版
     */
    private boolean cxM_ZONE(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }

    /**
     * M_ZONE Linght
     */
    private boolean M_ZONE_Linght(String data, ConditionRelation conditionRelation,Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(),conditionKey);
    }

    /**
     * 畅听赋能版（彩铃赋能版20221122新增）
     */
    private boolean listenEnergize(String data, ConditionRelation conditionRelation, Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(), conditionKey);
    }

    /**
     * 白金会员畅听体验版（20221122新增）
     */
    private boolean platinumListenExperience(String data, ConditionRelation conditionRelation, Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(), conditionKey);
    }

    /**
     * 星座-M会员（20221122新增）
     */
    private boolean constellationMVIP(String data, ConditionRelation conditionRelation, Integer conditionKey) {
        return super.getIdentifier(data, conditionRelation.getConditionData(), conditionRelation.getRelation(), conditionKey);
    }

    /**
     * 更具不同的子条件判断返回判断结果（子条件第一版只支持or）
     */
    @Override
    public boolean getMember(Map data, List<ConditionRelation> conditionRelations) {
        LinkedHashMap<Boolean, Integer> booleanIntegerLinkedHashMap = new LinkedHashMap<>();
        // 排序
        super.sort(conditionRelations);
        for (ConditionRelation conditionRelation : conditionRelations) {
            boolean vip = true;
            Object o = data.get(ConditionEnum.getKeyValue(conditionRelation.getPropertyCode(), conditionRelation.getConditionKey()));
            if (o==null||o.equals("")) {
                booleanIntegerLinkedHashMap.put(false,conditionRelation.getCConnector());
                break;
            }
            String value =o.toString();
            switch (conditionRelation.getConditionKey()) {
                case 1:
                    vip = this.noVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 2:
                    vip = this.superVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 3:
                    vip = this.psVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 4:
                    vip = this.platinaVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 5:
                    vip = this.bigStation(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 6:
                    vip = this.uniteVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 7:
                    vip = this.explatinaVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 8:
                    vip = this.hour(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 9:
                    vip = this.fiveG(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 10:
                    vip = this.music(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 11:
                    vip = this.noMusic(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 12:
                    vip = this.ikunVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 13:
                case 14:
                    vip = this.cxplatinaVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 15:
                    vip = this.ctplatinaVIP(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 16:
                    vip = this.dayAt(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 17:
                    vip = this.M_ZONE(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 18:
                    vip = this.custom(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 19:
                    vip = this.cxM_ZONE(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 20:
                    vip = this.M_ZONE_Linght(value, conditionRelation,conditionRelation.getConditionKey());
                    break;
                case 21:
                    vip = this.listenEnergize(value, conditionRelation, conditionRelation.getConditionKey());
                    break;
                case 22:
                    vip = this.platinumListenExperience(value, conditionRelation, conditionRelation.getConditionKey());
                    break;
                case 23:
                    vip = this.constellationMVIP(value, conditionRelation, conditionRelation.getConditionKey());
                    break;
                default:
                    break;
            }
            booleanIntegerLinkedHashMap.put(vip, conditionRelation.getCConnector());
        }
        return super.getRelation(booleanIntegerLinkedHashMap);
    }
}